home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.netobjects.nfx.ui.OrderedListModel;
- import asp.netobjects.nfx.util.ExceptionHandler;
- import asp.netobjects.nfx.util.ExternalError;
- import asp.netobjects.nfx.util.InternalError;
- import asp.netobjects.nfx.wizard.Wizard;
- import asp.netobjects.nfx.wizard.WizardPage;
- import asp.netobjects.nfx.wizard.WizardPageView;
- import asp.util.ResourceUtil;
- import asp.wizard.def.DefConnection;
- import com.sun.java.swing.DefaultListModel;
- import com.sun.java.swing.ImageIcon;
- import java.util.Vector;
-
- public class WizardModelSubDbQuerySelect extends WizardModelSub {
- WizardSubDbQuery _Wizard;
- WizardPage _joinPage;
- WizardPage _wherePage;
- SubDBQueryData _Data;
- WizardViewSubDbQuerySelect _viewInstance;
- // $FF: synthetic field
- static Class class$asp$wizard$WVPanelDbQuerySelect;
-
- public WizardModelSubDbQuerySelect() {
- }
-
- public WizardModelSubDbQuerySelect(Wizard wizard, String bullet, String info, ImageIcon icon, ExceptionHandler handler) {
- super(wizard, bullet, info, icon, handler);
- this._Wizard = (WizardSubDbQuery)wizard;
- this._Data = this._Wizard.getData();
- }
-
- protected WizardPageView getViewSingleInstance() {
- WizardViewSubDbQuerySelect wizard = (WizardViewSubDbQuerySelect)WizardViewSubDbQuerySelect.getInstance();
- return WizardViewSubDbQuerySelect.getInstance();
- }
-
- public void commit() throws InternalError, ExternalError {
- WizardViewSubDbQuerySelect view = (WizardViewSubDbQuerySelect)this.getViewSingleInstance();
- OrderedListModel olm = view.getFields();
- this._Data.removeAllFields();
-
- for(int i = 0; i < ((DefaultListModel)olm).getSize(); ++i) {
- String strData = ((DefaultListModel)olm).elementAt(i).toString();
- int nIndex = strData.indexOf(".");
- if (nIndex != -1) {
- String strTable = strData.substring(0, nIndex);
- String strField = strData.substring(nIndex + 1);
- this._Data.addField(strTable, strField);
- }
- }
-
- this._Data.updateAllPossibleFields();
- }
-
- public void updateTableComboBox() {
- WizardViewSubDbQuerySelect view = (WizardViewSubDbQuerySelect)((WizardPage)this).getView();
- boolean[] containingSpaceFound = new boolean[1];
- OrderedListModel list = this._Data.getTables(containingSpaceFound);
- if (containingSpaceFound[0]) {
- view.setContainingSpaceWarningVisible(true);
- }
-
- view.setTableComboBoxModel(list);
- }
-
- public void updateAvailableFieldList() {
- WizardViewSubDbQuerySelect view = (WizardViewSubDbQuerySelect)((WizardPage)this).getView();
- OrderedListModel olmAvailFields = new OrderedListModel();
- String selTableName = view.getSelectedTable();
- boolean[] containingSpaceFound = new boolean[1];
- if (selTableName != null && !selTableName.equals("")) {
- DefConnection dc = ((WizardSubDbQuery)((WizardPage)this).getWizard()).getDefConnection();
- SubDBQueryData.setFields(dc, olmAvailFields, selTableName, containingSpaceFound);
- olmAvailFields.setOrdered(true);
- }
-
- if (containingSpaceFound[0]) {
- view.setContainingSpaceWarningVisible(true);
- }
-
- view.setAvailableFieldModel(olmAvailFields);
- }
-
- public void loadView() {
- if (((WizardPage)this).getView() != null) {
- ((WizardViewSubDbQuerySelect)((WizardPage)this).getView()).setContainingSpaceWarningVisible(false);
- }
-
- this.updateTableComboBox();
- this.updateAvailableFieldList();
- this.loadValues();
- }
-
- public void loadValues() {
- Vector fields = this._Data.getFields();
- OrderedListModel olm = new OrderedListModel();
-
- for(int i = 0; i < fields.size(); ++i) {
- SubDBQueryData.FieldOb field = (SubDBQueryData.FieldOb)fields.elementAt(i);
- olm.addElement(field.getTable() + "." + field.getField());
- }
-
- WizardViewSubDbQuerySelect view = (WizardViewSubDbQuerySelect)((WizardPage)this).getView();
- view.setSelectedFields(olm);
- }
-
- public WizardPage createNext() {
- if (this._Wizard.getData().containsMultipleTables()) {
- this._joinPage = new WizardModelSubDbQueryJoin(this._Wizard, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
- return this._joinPage;
- } else {
- this._wherePage = new WizardModelSubDbQueryWhere(this._Wizard, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
- return this._wherePage;
- }
- }
-
- public void validate() throws InternalError, ExternalError {
- super.validate();
- WizardViewSubDbQuerySelect view = (WizardViewSubDbQuerySelect)this.getViewSingleInstance();
- OrderedListModel olm = view.getFields();
- if (((DefaultListModel)olm).size() == 0) {
- String msg = ResourceUtil.getResourceString("asp.wizard.res", class$asp$wizard$WVPanelDbQuerySelect != null ? class$asp$wizard$WVPanelDbQuerySelect : (class$asp$wizard$WVPanelDbQuerySelect = class$("asp.wizard.WVPanelDbQuerySelect")), "err.selectfield");
- throw new ExternalError(msg);
- }
- }
-
- public WizardPage getNext() {
- WizardPage result = null;
- if (this._Wizard.getData().containsMultipleTables()) {
- if (this._joinPage == null) {
- this._joinPage = new WizardModelSubDbQueryJoin(this._Wizard, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
- }
-
- this._joinPage.setPrevious(this);
- if (this._wherePage != null) {
- this._joinPage.setNext(this._wherePage);
- this._wherePage.setPrevious(this._joinPage);
- }
-
- result = this._joinPage;
- } else {
- if (this._wherePage == null) {
- WizardPage afterJoin = null;
-
- try {
- if (this._joinPage != null) {
- afterJoin = this._joinPage.getNext();
- }
- } catch (ExternalError var3) {
- } catch (InternalError var4) {
- }
-
- if (afterJoin != null) {
- this._wherePage = afterJoin;
- } else {
- this._wherePage = new WizardModelSubDbQueryWhere(this._Wizard, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
- }
- }
-
- this._wherePage.setPrevious(this);
- result = this._wherePage;
- }
-
- return result;
- }
-
- public Object handleGetItemToXfer(Object sourceItem) {
- WizardViewSubDbQuerySelect view = (WizardViewSubDbQuerySelect)((WizardPage)this).getView();
- String s = view.getSelectedTable();
- if (s != null && !s.equals("")) {
- StringBuffer sb = new StringBuffer(s);
- sb.append(".");
- sb.append(sourceItem.toString());
- return sb.toString();
- } else {
- return null;
- }
- }
-
- // $FF: synthetic method
- static Class class$(String class$) {
- try {
- return Class.forName(class$);
- } catch (ClassNotFoundException forName) {
- throw new NoClassDefFoundError(((Throwable)forName).getMessage());
- }
- }
- }
-